﻿using Newtonsoft.Json;

namespace OneWorks.Web.Common.BaiDu.Geocoding
{
    public class BaiduGeocodingResults
    {
        /// <summary>
        /// 返回结果状态值， 成功返回0，其他值请查看附录。
        /// </summary>
        [JsonProperty(PropertyName = "status")]
        public Status Status;

        /// <summary>
        /// 返回结果状态值， 成功返回0，其他值请查看附录。
        /// </summary>
        [JsonProperty(PropertyName = "result")]
        public BaiduGeocodingResult Result;
    }

    public class BaiduGeocodingResult
    {
        /// <summary>
        /// 经纬度坐标
        /// </summary>
        [JsonProperty(PropertyName = "location")]
        public BaiduGeocodingLoaction Location;
        /// <summary>
        /// 位置的附加信息，是否精确查找。1为精确查找，0为不精确。
        /// </summary>
        [JsonProperty(PropertyName = "precise")]
        public int Precise;
        /// <summary>
        /// 可信度
        /// </summary>
        [JsonProperty(PropertyName = "confidence")]
        public int Confidence;
        /// <summary>
        /// 地址类型
        /// </summary>
        [JsonProperty(PropertyName = "level")]
        public string Level;

        /// <summary>
        /// 结构化地址信息
        /// </summary>
        [JsonProperty(PropertyName = "formatted_address")]
        public string FormattedAddress;

        /// <summary>
        /// 所在商圈信息，如 "人民大学,中关村,苏州街"
        /// </summary>
        [JsonProperty(PropertyName = "business")]
        public string Business;

        /// <summary>
        /// 具体地址
        /// </summary>
        [JsonProperty(PropertyName = "addressComponent")]
        public BaiduGeocodingAddress AddressComponent;
    }

    public class BaiduGeocodingLoaction
    {
        /// <summary>
        /// 纬度值
        /// </summary>
        [JsonProperty(PropertyName = "lat")]
        public decimal Lat;
        /// <summary>
        /// 经度值
        /// </summary>
        [JsonProperty(PropertyName = "lng")]
        public decimal Lng;
    }

    public class BaiduGeocodingAddress
    {
        /// <summary>
        /// 城市名
        /// </summary>
        [JsonProperty(PropertyName = "city")]
        public string City;
        /// <summary>
        /// 区县名
        /// </summary>
        [JsonProperty(PropertyName = "district")]
        public string District;
        /// <summary>
        /// 省名
        /// </summary>
        [JsonProperty(PropertyName = "province")]
        public string Province;
        /// <summary>
        /// 街道名
        /// </summary>
        [JsonProperty(PropertyName = "street")]
        public string Street;
        /// <summary>
        /// 街道门牌号
        /// </summary>
        [JsonProperty(PropertyName = "street_number")]
        public string StreetNumber;
    }
}
